package com.xingongchang.baolebei.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.afinal.simplecache.ACache;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.R.integer;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;

import com.external.androidquery.callback.AjaxStatus;
import com.google.gson.JsonObject;
import com.insthub.BeeFramework.model.BaseModel;
import com.insthub.BeeFramework.model.BeeCallback;
import com.insthub.BeeFramework.view.ToastView;
import com.xingongchang.baolebei.BaolebeiApp;
import com.xingongchang.baolebei.R;
import com.xingongchang.baolebei.protocol.AD;
import com.xingongchang.baolebei.protocol.CATEGORY;
import com.xingongchang.baolebei.protocol.LETTER;
import com.xingongchang.baolebei.protocol.LETTER_DETAIL;
import com.xingongchang.baolebei.protocol.PAGINATION;
import com.xingongchang.baolebei.protocol.RECOMMEND_GOODS;
import com.xingongchang.baolebei.protocol.SESSION;
import com.xingongchang.baolebei.protocol.STATUS;
import com.xingongchang.baolebei.protocol.TOPIC;
import com.xingongchang.baolebei.protocol.TOPIC_COMMENT;
import com.xingongchang.baolebei.protocol.TOPIC_DETAIL;
import com.xingongchang.baolebei.protocol.USER;
import com.xingongchang.baolebei.protocol.USER_INFO;
import com.xingongchang.baolebei.protocol.USER_TOPIC;
import com.xingongchang.baolebei.protocol.User_tan;


public class UserInfoModel extends BaseModel {
	private SharedPreferences shared;
	private SharedPreferences.Editor editor;
	public USER user;
	public USER_INFO userinfo;
	public ArrayList<USER_TOPIC> usertopicList = new ArrayList<USER_TOPIC>();
	public ArrayList<LETTER> letterlist = new ArrayList<LETTER>();
	public ArrayList<LETTER_DETAIL> letterdetails = new ArrayList<LETTER_DETAIL>();
	public static final int RANK_LEVEL_NORMAL = 0;
	public static final int RANK_LEVEL_VIP = 1;
	public static final int PAGE_COUNT = 15;
	public static final int PAGE_COUNT_LETTER = 4;
	public ArrayList<TOPIC> topicList = new ArrayList<TOPIC>();
	public ArrayList<AD> adList = new ArrayList<AD>();
	public ArrayList<TOPIC_COMMENT> commentList = new ArrayList<TOPIC_COMMENT>();
	public ArrayList<RECOMMEND_GOODS> recommendGoods = new ArrayList<RECOMMEND_GOODS>();
	public ArrayList<User_tan> user_tanarraTans = new ArrayList<User_tan>();
	public TOPIC_DETAIL topicDetail;
    public int Usign;
    public STATUS responseStatus;
    public  ProgressDialog pd;
    ACache cache;
	
	public UserInfoModel(Context context) {
		super(context);
		cache=ACache.get(mContext);
		this.mContext=context;
	}
	/**
	 * 论坛分类
	 */
	public void Forum(){
		String url = ProtocolConst.USER_TAN;
		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {
			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));
					user_tanarraTans.clear();
					if (responseStatus.succeed == 1) {
						JSONArray categoryArray = jo.optJSONArray("data");
						cache.put("categoryData", categoryArray);
                        if (null != categoryArray && categoryArray.length() > 0)
                        {
                            for (int i = 0; i < categoryArray.length(); i++)
                            {
                                JSONObject categoryObject = categoryArray.getJSONObject(i);
                                User_tan category = User_tan.fromJson(categoryObject);
                                user_tanarraTans.add(category);
                            }
                        }
					}else{
						Toast.makeText(mContext, ""+responseStatus.error_desc, 0).show();
					}
				     UserInfoModel.this.OnMessageResponse(url, jo, status);
				} catch (JSONException e) {
					e.printStackTrace();
				}
			}
		};
		cb.url(url).type(JSONObject.class);
		aq.ajax(cb);
	}
	/**
	 * 查看是否有未读私信USER_STATUS_LETTER
	 */
	public void getLetter(){
		String url = ProtocolConst.USER_STATUS_LETTER;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {
			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				STATUS responseStatus;
				try {
					responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));
					if (responseStatus.succeed == 1) {
						JSONObject jsonObject=jo.optJSONObject("data");
						Usign=jsonObject.getInt("sign");
					  }else{
						 Toast.makeText(mContext, ""+responseStatus.error_desc, 0).show();
					  }
					  UserInfoModel.this.OnMessageResponse(url, jo, status);
				} catch (JSONException e) {
					e.printStackTrace();
				}

			}
		};
		SESSION session = SESSION.getInstance();
		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("userid", session.uid);
		} catch (JSONException e) {
			// TODO: handle exception
		}

		params.put("json", requestJsonObject.toString());
		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	public void getUserInfo() {

		String url = ProtocolConst.USERINFO;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {

				UserInfoModel.this.callback(url, jo, status);

				try {
				 responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						cache.put("objects", jo.optJSONObject("data"));
						user = USER.fromJson(jo.optJSONObject("data"));
						user.save();
						
					}else{
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					  }
					  UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {

					e.printStackTrace();
				}

			}

		};

		SESSION session = SESSION.getInstance();

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("session",session.toJson());
		} catch (JSONException e) {

		}

		params.put("json", requestJsonObject.toString());
		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);

	}

	/**
	 * 更改论坛头像和资料
	 */
	public void setTopicUserInfo(String name, String pic, int sex) {

		String url = ProtocolConst.EDIT_USER_INFO;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {

				UserInfoModel.this.callback(url, jo, status);

				try {
				 responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						
					}else{
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					  }
					  UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					e.printStackTrace();
				}

			}

		};

		SESSION session = SESSION.getInstance();

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("userid", session.uid);
			requestJsonObject.put("img", pic);
			requestJsonObject.put("nickname",name);
			requestJsonObject.put("sex", sex);
		} catch (JSONException e) {
		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);

	}
	/**
	 * 更改密码
	 */
	public void setUserPwd(String onepwd, String twopwd){
		String url = ProtocolConst.EDIT_USER_INFO;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {

				UserInfoModel.this.callback(url, jo, status);

				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
					}else{
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					  }
					  UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {

					e.printStackTrace();
				}

			}

		};

		SESSION session = SESSION.getInstance();

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("userid", session.uid);
			requestJsonObject.put("old_password",onepwd);
			requestJsonObject.put("new_password", twopwd);
		} catch (JSONException e) {
		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);
	}
	
	/*
	 * 修改帖子,String unChangeImg
	 */
	public void UpdateDatails(int topic_id,String title,String body,JSONArray imgs,String unChangeImg){
		String url = ProtocolConst.UPDATE_TOPIC;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {
			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
				  responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));
					if (responseStatus.succeed == 1) {
						
					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);
				} catch (JSONException e) {
					e.printStackTrace();
				}
			 }
		};
		SESSION session = SESSION.getInstance();
		JSONObject requestJsonObject = new JSONObject();
		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("topicid",topic_id);
			requestJsonObject.put("title", title);
			requestJsonObject.put("body",body);
			requestJsonObject.put("userid",session.uid);
			requestJsonObject.put("isanonymous",0);
//			requestJsonObject.put("img", imgs);
			requestJsonObject.put("unChangeImg",unChangeImg);
//			requestJsonObject.put("newImg", imgs);
			requestJsonObject.put("newImg", imgs);
		} catch (JSONException e) {
		}
		params.put("json", requestJsonObject.toString());
		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);
	}
	//商品评论
	public void getCounment(int goods_id,int start,String conent,int order_id){
		String url = ProtocolConst.criticism;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {
			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
					try {
						responseStatus = STATUS.fromJson(jo
								.optJSONObject("status"));
						if (responseStatus.succeed == 1) {
							
						}else if(responseStatus.succeed == 0){
							ToastView toast = new ToastView(mContext,responseStatus.error_desc);
							toast.setGravity(Gravity.CENTER, 0, 0);
							toast.show();	
						}
						UserInfoModel.this.OnMessageResponse(url, jo, status);
					} catch (JSONException e) {
						e.printStackTrace();
					}
			}
		};
		SESSION session=SESSION.getInstance();
		JSONObject requestJsonObject = new JSONObject();
		JSONObject json = new JSONObject();
	    try {
			json.put("sid", session.sid);
			json.put("uid", session.uid);
		} catch (JSONException e1) {
			e1.printStackTrace();
		}
		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("goods_id",goods_id);
			requestJsonObject.put("star", start);
			requestJsonObject.put("session",json);
			requestJsonObject.put("content",conent);
			requestJsonObject.put("order_id",order_id);
		} catch (JSONException e) {
		}
		params.put("json", requestJsonObject.toString());
		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);
	}
	/**
	 * 论坛用户信息
	 */
	public void getTopicUserInfo(String id) {

		String url = ProtocolConst.USER_INFO;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {

				UserInfoModel.this.callback(url, jo, status);

				try {
					responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						userinfo = USER_INFO.fromJson(jo.optJSONObject("data"));
						BaolebeiApp.userinfo = userinfo;
					}else if(responseStatus.succeed == 0){
//						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
//						toast.setGravity(Gravity.CENTER, 0, 0);
//						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {

					e.printStackTrace();
				}

			}

		};

		SESSION session = SESSION.getInstance();

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("userid", id);
		} catch (JSONException e) {

		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
//		aq.ajax(cb);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);

	}

	/**
	 * 论坛金币
	 */
	public void getCoin() {

		String url = ProtocolConst.COIN;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {

				UserInfoModel.this.callback(url, jo, status);

				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {

					e.printStackTrace();
				}

			}

		};

		SESSION session = SESSION.getInstance();

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("userid", session.uid);
		} catch (JSONException e) {

		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);

	}

	public void getUserTopic() {
		String url = ProtocolConst.USER_TOPIC;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						JSONArray topicJsonArray = jo.optJSONArray("data");

						usertopicList.clear();
						if (null != topicJsonArray
								&& topicJsonArray.length() > 0) {
							usertopicList.clear();
							for (int i = 0; i < topicJsonArray.length(); i++) {
								JSONObject topicJsonObject = topicJsonArray
										.getJSONObject(i);
								USER_TOPIC topic = USER_TOPIC.fromJson(topicJsonObject);
								usertopicList.add(topic);
							}
						}

					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}

			}

		};

		PAGINATION pagination = new PAGINATION();
		pagination.page = 1;
		pagination.count = PAGE_COUNT;

		SESSION session = SESSION.getInstance();
		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("pagination", pagination.toJson());
			requestJsonObject.put("userid", session.uid);
		} catch (JSONException e) {
			// TODO: handle exception
		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);

		Resources resource = mContext.getResources();
		String wait = resource.getString(R.string.hold_on);
		pd.setMessage(wait);
		aq.progress(pd).ajax(cb);

	}

	@SuppressWarnings("unchecked")
	public void getUserTopicMore() {
		String url = ProtocolConst.USER_TOPIC;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						JSONArray topicJsonArray = jo.optJSONArray("data");

						if (null != topicJsonArray
								&& topicJsonArray.length() > 0) {
							for (int i = 0; i < topicJsonArray.length(); i++) {
								JSONObject topicJsonObject = topicJsonArray
										.getJSONObject(i);
								USER_TOPIC topic = USER_TOPIC.fromJson(topicJsonObject);
								usertopicList.add(topic);
							}
						}


					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}

			}

		};

		PAGINATION pagination = new PAGINATION();
		pagination.page = (int) Math.ceil((double) usertopicList.size() * 1.0
				/ PAGE_COUNT) + 1;
		pagination.count = PAGE_COUNT;

		SESSION session = SESSION.getInstance();
		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("pagination", pagination.toJson());
			requestJsonObject.put("userid", session.uid);
		} catch (JSONException e) {
			// TODO: handle exception
		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
		aq.ajax(cb);

	}
	
	/**
	 * 删除帖子
	 */
	public void deleteTopic(int topicid) {

		String url = ProtocolConst.DELETE_TOPIC;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {

				UserInfoModel.this.callback(url, jo, status);

				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						
					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {

					e.printStackTrace();
				}

			}

		};

		SESSION session = SESSION.getInstance();

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("userid", session.uid);
			requestJsonObject.put("topicid", topicid+"");
		} catch (JSONException e) {

		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);

	}
	
	
	/**
	 * 发布帖子
	 */
	public void sendTopic(String title,String content,JSONArray imgs,int cat_id) {

		String url = ProtocolConst.SEND_TOPIC;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {

				UserInfoModel.this.callback(url, jo, status);

				try {
				  responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						
					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {

					e.printStackTrace();
				}

			}

		};

		SESSION session = SESSION.getInstance();

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("title", title);
			requestJsonObject.put("body", content);
			requestJsonObject.put("userId", session.uid);
			requestJsonObject.put("isanonymous", "0");
			requestJsonObject.put("imgs", imgs);
			requestJsonObject.put("cat_id", cat_id);
		} catch (JSONException e) {
		}
		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);
	}
	
	/**
	 * 获取用户私信列表
	 */
	public void getUserLetter() {
		
		String url = ProtocolConst.USER_LETTER;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					 responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						JSONArray letterJsonArray = jo.optJSONArray("data");

						letterlist.clear();
						if (null != letterJsonArray
								&& letterJsonArray.length() > 0) {
							letterlist.clear();
							for (int i = 0; i < letterJsonArray.length(); i++) {
								JSONObject letterJsonObject = letterJsonArray
										.getJSONObject(i);
								LETTER letter = LETTER.fromJson(letterJsonObject);
								letterlist.add(letter);
							}
						}
					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}
			}
		};

		PAGINATION pagination = new PAGINATION();
		pagination.page = 1;
		pagination.count = PAGE_COUNT;

		SESSION session = SESSION.getInstance();
		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("pagination", pagination.toJson());
			requestJsonObject.put("userid", session.uid);
		} catch (JSONException e) {
			// TODO: handle exception
		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);

		Resources resource = mContext.getResources();
		String wait = resource.getString(R.string.hold_on);
		pd.setMessage(wait);
		aq.progress(pd).ajax(cb);

	}

	//获取更多用户私信
	public void getUserLetterMore() {
		String url = ProtocolConst.USER_LETTER;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {

						JSONArray letterJsonArray = jo.optJSONArray("data");

						if (null != letterJsonArray
								&& letterJsonArray.length() > 0) {
							for (int i = 0; i < letterJsonArray.length(); i++) {
								JSONObject letterJsonObject = letterJsonArray
										.getJSONObject(i);
								LETTER letter = LETTER.fromJson(letterJsonObject);
								letterlist.add(letter);
							}
						}

					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}

			}

		};

		PAGINATION pagination = new PAGINATION();
		pagination.page = (int) Math.ceil((double) letterlist.size() * 1.0
				/ PAGE_COUNT) + 1;
		pagination.count = PAGE_COUNT;

		SESSION session = SESSION.getInstance();
		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("pagination", pagination.toJson());
			requestJsonObject.put("userid", session.uid);
		} catch (JSONException e) {
			// TODO: handle exception
		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
		aq.ajax(cb);
	}
	
	
	/**
	 * 获取用户私信详情列表
	 */
	public void getUserDetailLetter(int receiverid) {
		
		String url = ProtocolConst.USER_READ_LETTER;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						JSONArray letterdetailsJsonArray = jo.optJSONArray("data");
						letterdetails.clear();
						if (null != letterdetailsJsonArray && letterdetailsJsonArray.length() > 0) {
							letterdetails.clear();
							for (int i = letterdetailsJsonArray.length() - 1; i >= 0; i--) {
								JSONArray itemJSONArray = letterdetailsJsonArray.getJSONArray(i);
								for(int j = itemJSONArray.length() - 1; j >= 0; j--){
									JSONObject itemJSONObject = itemJSONArray.getJSONObject(j);
									LETTER_DETAIL letterDetail = LETTER_DETAIL.fromJson(itemJSONObject);
									letterdetails.add(letterDetail);
								}
							}
						}
					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}
			}
		};

		PAGINATION pagination = new PAGINATION();
		pagination.page = 1;
		pagination.count = PAGE_COUNT_LETTER;

		SESSION session = SESSION.getInstance();
		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("pagination", pagination.toJson());
			requestJsonObject.put("userid", session.uid);
			requestJsonObject.put("otherid", receiverid);
			
		} catch (JSONException e) {
			// TODO: handle exception
		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
//		aq.ajax(cb);
		ProgressDialog pd = new ProgressDialog(mContext);

		Resources resource = mContext.getResources();
		String wait = resource.getString(R.string.hold_on);
		pd.setMessage(wait);
		aq.progress(pd).ajax(cb);

	}
	
	
	/**
	 * 获取更多用户私信详情列表
	 */
	public void getUserDetailLetterMore(int receiverid) {
		
		String url = ProtocolConst.USER_READ_LETTER;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						JSONArray letterdetailsJsonArray = jo.optJSONArray("data");
					    ArrayList<LETTER_DETAIL> list = new ArrayList<LETTER_DETAIL>();
						if (null != letterdetailsJsonArray && letterdetailsJsonArray.length() > 0) {
							for (int i = letterdetailsJsonArray.length() - 1; i >= 0 ; i--) {
								JSONArray itemJSONArray = letterdetailsJsonArray.getJSONArray(i);
								for(int j = itemJSONArray.length() - 1; j >= 0 ; j--){
									JSONObject itemJSONObject = itemJSONArray.getJSONObject(j);
									LETTER_DETAIL letterDetail = LETTER_DETAIL.fromJson(itemJSONObject);
									list.add(letterDetail);
								}
							}
							letterdetails.addAll(0, list);
						}
						for(int i = 0;i<letterdetails.size();i++){
							Log.i("Api", letterdetails.get(i).content);
						}
					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}
			}
		};
		PAGINATION pagination = new PAGINATION();
		pagination.page = (int) Math.ceil((double) letterdetails.size() * 1.0
				/ PAGE_COUNT_LETTER) + 1;
		pagination.count = PAGE_COUNT_LETTER;

		SESSION session = SESSION.getInstance();
		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("pagination", pagination.toJson());
			requestJsonObject.put("userid", session.uid);
			requestJsonObject.put("otherid", receiverid);
			
		} catch (JSONException e) {
			// TODO: handle exception
		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
		aq.ajax(cb);
//		ProgressDialog pd = new ProgressDialog(mContext);
//		Resources resource = mContext.getResources();
//		String wait = resource.getString(R.string.hold_on);
//		pd.setMessage(wait);
//		aq.progress(pd).ajax(cb);

	}
	
	
	
	/**
	 * 发送私信
	 */
	public void sendLetter(int receiver,String content) {

		String url = ProtocolConst.USER_SEND_LETTER;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {

				UserInfoModel.this.callback(url, jo, status);
				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));
					if (responseStatus.succeed == 1) {
						UserInfoModel.this.OnMessageResponse(url, jo, status);
						return;
					}else if(responseStatus.succeed==0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
                        toast.setGravity(Gravity.CENTER, 0, 0);
                        toast.show();
                        return;
					}
				} catch (JSONException e) {
					e.printStackTrace();
				}
			}
		};
		SESSION session = SESSION.getInstance();
		JSONObject requestJsonObject = new JSONObject();
		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("sender", session.uid);
			requestJsonObject.put("receiver", receiver+""); 
			requestJsonObject.put("content", content);
			
		} catch (JSONException e) {}
		params.put("json", requestJsonObject.toString());
		cb.url(url).type(JSONObject.class).params(params);
//		aq.ajax(cb);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);

	}
	
	/**
	 * 删除帖子
	 */
	public void deleteLetter(int friendid,String time) {

		String url = ProtocolConst.DELETE_LETTER;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {

				UserInfoModel.this.callback(url, jo, status);

				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						
					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {

					e.printStackTrace();
				}

			}

		};

		SESSION session = SESSION.getInstance();

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("userid", session.uid);
			requestJsonObject.put("otherid", friendid+"");
			requestJsonObject.put("time", time);
		} catch (JSONException e) {

		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);
		pd.setMessage(mContext.getResources().getString(R.string.hold_on));
		aq.progress(pd).ajax(cb);

	}
	
	/**
	 * 获取帖子列表
	 */
	public void getTopic(int case_id) {
		String url = ProtocolConst.TOPIC;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
				 responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						JSONArray topicJsonArray = jo.optJSONArray("data");

						topicList.clear();
						if (null != topicJsonArray
								&& topicJsonArray.length() > 0) {
							topicList.clear();
							for (int i = 0; i < topicJsonArray.length(); i++) {
								JSONObject topicJsonObject = topicJsonArray
										.getJSONObject(i);
								TOPIC topic = TOPIC.fromJson(topicJsonObject);
								topicList.add(topic);
							}
						}else{
							topicList.clear();
						}
					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}

			}

		};

		PAGINATION pagination = new PAGINATION();
		pagination.page = 1;
		pagination.count = PAGE_COUNT;

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("pagination", pagination.toJson());
			requestJsonObject.put("cat_id",case_id);
		} catch (JSONException e) {
			// TODO: handle exception
		}

		params.put("json", requestJsonObject.toString());

		cb.url(url).type(JSONObject.class).params(params);
//		aq.ajax(cb);
		ProgressDialog pd = new ProgressDialog(mContext);

		Resources resource = mContext.getResources();
		String wait = resource.getString(R.string.hold_on);
		pd.setMessage(wait);
		aq.progress(pd).ajax(cb);

	}

	/**
	 * 获取更多帖子列表
	 */
	public void getTopicMore(int case_id) {
		String url = ProtocolConst.TOPIC;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						JSONArray topicJsonArray = jo.optJSONArray("data");

						if (null != topicJsonArray
								&& topicJsonArray.length() > 0) {
							for (int i = 0; i < topicJsonArray.length(); i++) {
								JSONObject topicJsonObject = topicJsonArray
										.getJSONObject(i);
								TOPIC topic = TOPIC.fromJson(topicJsonObject);
								topicList.add(topic);
							}
						}


					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}

			}

		};

		PAGINATION pagination = new PAGINATION();
		pagination.page = (int) Math.ceil((double) topicList.size() * 1.0
				/ PAGE_COUNT) + 1;
		pagination.count = PAGE_COUNT;

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("pagination", pagination.toJson());
			requestJsonObject.put("cat_id",case_id);
		} catch (JSONException e) {
			// TODO: handle exception
		}
		params.put("json", requestJsonObject.toString());
		cb.url(url).type(JSONObject.class).params(params);
		ProgressDialog pd = new ProgressDialog(mContext);
		Resources resource = mContext.getResources();
		String wait = resource.getString(R.string.hold_on);
		pd.setMessage(wait);
		aq.progress(pd).ajax(cb);
	}

	// 获取轮播帖子图片信息
	public void getAd() {
		String url = ProtocolConst.AD;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						JSONArray adJsonArray = jo.optJSONArray("data");
						cache.put("adverta", adJsonArray);
						if (null != adJsonArray && adJsonArray.length() > 0) {
							adList.clear();
							for (int i = 0; i < adJsonArray.length(); i++) {
								JSONObject adJsonObject = adJsonArray
										.getJSONObject(i);
								AD ad = AD.fromJson(adJsonObject);
								adList.add(ad);
							}
						}


					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}

			}

		};
		cb.url(url).type(JSONObject.class);
		aq.ajax(cb);

	}

	/**
	 * 获取帖子详情
	 * 
	 * @param topicid
	 */
	public void getTopicDetails(int topicid) {
		String url = ProtocolConst.TOPIC_DETAIL;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					 responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						JSONObject dataobj = jo.optJSONObject("data");
						topicDetail = TOPIC_DETAIL.fromJson(dataobj
								.optJSONObject("detail"));
						JSONArray goodsArray = dataobj.optJSONArray("goods");

						recommendGoods.clear();
						if (null != goodsArray && goodsArray.length() > 0) {
							recommendGoods.clear();
							for (int i = 0; i < goodsArray.length(); i++) {
								JSONObject goodsObject = goodsArray
										.getJSONObject(i);
								RECOMMEND_GOODS goods = RECOMMEND_GOODS
										.fromJson(goodsObject);
								recommendGoods.add(goods);
							}
						}
					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}

			}

		};

		PAGINATION pagination = new PAGINATION();
		pagination.page = 1;
		pagination.count = PAGE_COUNT;

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("pagination", pagination.toJson());
			requestJsonObject.put("topicid", topicid + "");
		} catch (JSONException e) {
			// TODO: handle exception
		}

		params.put("json", requestJsonObject.toString());
		cb.url(url).type(JSONObject.class).params(params);
//		aq.ajax(cb);
		ProgressDialog pd = new ProgressDialog(mContext);

		Resources resource = mContext.getResources();
		String wait = resource.getString(R.string.hold_on);
		pd.setMessage(wait);
		aq.progress(pd).ajax(cb);

	}

	/**
	 * 获取帖子评论列表
	 * 
	 * @param topicid
	 */
	public void getTopicComment(int topicid) {
		
		String url = ProtocolConst.TOPIC_COMMENT;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					STATUS responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						JSONArray commentJsonArray = jo.optJSONArray("data");
						commentList.clear();
						if (null != commentJsonArray
								&& commentJsonArray.length() > 0) {
							commentList.clear();
							for (int i = 0; i < commentJsonArray.length(); i++) {
								JSONObject commentJsonObject = commentJsonArray
										.getJSONObject(i);
								TOPIC_COMMENT comment = TOPIC_COMMENT.fromJson(commentJsonObject);
								commentList.add(comment);
							}
						}else{
							commentList.clear();
						}

					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}

			}

		};

		PAGINATION pagination = new PAGINATION();
		pagination.page = 1;
		pagination.count = PAGE_COUNT;

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("pagination", pagination.toJson());
			requestJsonObject.put("topicid", topicid + "");
		} catch (JSONException e) {
			// TODO: handle exception
		}

		params.put("json", requestJsonObject.toString());
		cb.url(url).type(JSONObject.class).params(params);
//		aq.ajax(cb);
		ProgressDialog pd = new ProgressDialog(mContext);

		Resources resource = mContext.getResources();
		String wait = resource.getString(R.string.hold_on);
		pd.setMessage(wait);
		aq.progress(pd).ajax(cb);

	}

	/**
	 * 获取更多帖子评论列表
	 * 
	 * @param topicid
	 */
	public void getTopicCommentMore(int topicid) {
		
		String url = ProtocolConst.TOPIC_COMMENT;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));

					if (responseStatus.succeed == 1) {
						JSONArray commentJsonArray = jo.optJSONArray("data");
						if (null != commentJsonArray
								&& commentJsonArray.length() > 0) {
							for (int i = 0; i < commentJsonArray.length(); i++) {
								JSONObject commentJsonObject = commentJsonArray
										.getJSONObject(i);
								TOPIC_COMMENT comment = TOPIC_COMMENT.fromJson(commentJsonObject);
								commentList.add(comment);
							}
						}

					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}

			}

		};

		PAGINATION pagination = new PAGINATION();
		pagination.page = (int) Math.ceil((double) commentList.size() * 1.0
				/ PAGE_COUNT) + 1;
		pagination.count = PAGE_COUNT;

		JSONObject requestJsonObject = new JSONObject();

		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("pagination", pagination.toJson());
			requestJsonObject.put("topicid", topicid + "");
		} catch (JSONException e) {
			// TODO: handle exception
		}

		params.put("json", requestJsonObject.toString());
		cb.url(url).type(JSONObject.class).params(params);
//		aq.ajax(cb);

		ProgressDialog pd = new ProgressDialog(mContext);

		Resources resource = mContext.getResources();
		String wait = resource.getString(R.string.hold_on);
		pd.setMessage(wait);
		aq.progress(pd).ajax(cb);

	}

	public void getTopicReply(int topicid,String body) {
		
		String url = ProtocolConst.TOPIC_REPLY;

		BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() {

			@Override
			public void callback(String url, JSONObject jo, AjaxStatus status) {
				UserInfoModel.this.callback(url, jo, status);
				try {
					responseStatus = STATUS.fromJson(jo
							.optJSONObject("status"));
					if (responseStatus.succeed == 1) {
						
					}else if(responseStatus.succeed == 0){
						ToastView toast = new ToastView(mContext,responseStatus.error_desc);
						toast.setGravity(Gravity.CENTER, 0, 0);
						toast.show();	
					}
					UserInfoModel.this.OnMessageResponse(url, jo, status);

				} catch (JSONException e) {
					// TODO: handle exception
				}
			}
		};
		
		SESSION session = SESSION.getInstance();
		JSONObject requestJsonObject = new JSONObject();
		Map<String, String> params = new HashMap<String, String>();
		try {
			requestJsonObject.put("topicid", topicid+"");
			requestJsonObject.put("userid", session.uid);
			requestJsonObject.put("body", body);

		} catch (JSONException e) {
			// TODO: handle exception
		}
		params.put("json", requestJsonObject.toString());
		cb.url(url).type(JSONObject.class).params(params);
//		aq.ajax(cb);
		ProgressDialog pd = new ProgressDialog(mContext);
		Resources resource = mContext.getResources();
		String wait = resource.getString(R.string.hold_on);
		pd.setMessage(wait);
		aq.progress(pd).ajax(cb);

	}

}
